#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include<QPainter>
#include<QPainterPath>
#include<QKeyEvent>
#include<QTimer>
#include<QtMath>
#include<QDebug>
#include<QRadialGradient>


QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    void DrawDigital(QPainter &painter,int radius);
    void DrawCircle(QPainter &painter,int radius);
    void DrawSmallScale(QPainter &painter,int radius);
    void DrawBigScale(QPainter &painter,int radius);
    void DrawUnit(QPainter &painter,int radius);
    void DrawNum(QPainter &painter,int radius);
    void DrawPointer(QPainter &painter,int radius);
    void DrawCircle_line(QPainter& painter,int radius);
    void DrawCircle_bom_big(QPainter& painter,int radius);
    void DrawCircle_bom_shine(QPainter& painter,int radius);
    void DrawCircle_bom_small(QPainter& painter,int radius);
    void DrawCircle_arc(QPainter& painter,int radius);


protected:
    virtual void paintEvent(QPaintEvent *event) override;
    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent *event) override;
    virtual void keyPressEvent(QKeyEvent *event) override;
    virtual void keyReleaseEvent(QKeyEvent *event) override;

private slots:
    void speed_changed();

private:
    Ui::Widget *ui;
    //计时器
    QTimer *timer;
    //仪表盘的中心位置
    int radius;
    //指针运动的方向，1为前进，0为后退
    int direction;
    //当前速度
    int degRotate=0;
    bool is_Pressed=false;
};
#endif // WIDGET_H
